package com.pingpang.common.code.impl;

import java.io.IOException;

import com.alibaba.fastjson.JSON;
import com.pingpang.common.code.MessageCodecUtil;

public class JSONCodeUtil implements MessageCodecUtil{

	@Override
	public byte[] encode(Object message) throws IOException {
		return JSON.toJSONBytes(message);
	}

	@SuppressWarnings({ "rawtypes", "unchecked" })
	@Override
	public Object decode(byte[] body, Class cls) throws IOException {
		return JSON.parseObject(new String(body), cls);
	}

}
